<template>
  <div class="fenye" v-if="total">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="sizes"
      :page-size="params.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>


<script>
export default {
  name: "Page",
  data() {
    return {
      total: null,
      currentPage: 1,
      sizes: [10, 20, 30, 40],
      params: {
        page: 1,
        size: 10,
      },
    };
  },
  created() {
    this.getLists();
  },
  methods: {
    getLists() {
      var that = this;
      userList(this.params)
        .then((res) => {
          that.tableData = res.data.data;
          that.total = res.data.total;
          // console.log(res.data);
        })
        .catch((error) => {});
    },
    handleSizeChange(val) {
      this.params.size = val;
      this.getLists(this.params);
    },
    handleCurrentChange(val) {
      this.params.page = val;
      this.currentPage = val;
      this.getLists(this.params);
    },
  },
};
</script>
